package exercise;

public class ThreadProcess {
	 public volatile boolean flag =false;
	 public void printdigit(){
			 synchronized (this) {
//				 for(int i=1;i<26;i++){			 
				 for(int i=1;i<=52;i++){
					 System.out.print(i);
					 while(flag&&i%2==0){
					 try {
							this.wait();
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					 }					
//					   System.out.print(2*(i-1)+1);					   
//					   System.out.print(2*i);
					   flag=true;
					   this.notifyAll();
				   
			   }
		}  	
		 }
		 
	 
	 public void printdata(){
			 synchronized (this) {
				 for(int i=0;i<=25;i++){
					 while(!flag){
					 try {							
							this.wait();
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					 }
					 System.out.print((char)('A' + i));
					flag=false;
					this.notifyAll();
			 }	    
		 }
		 
	 }
}
